#!/user/bin/env python
#-*- encoding:utf-8 -*-
import socket
import thread
import threading

def connToServer():
    #创建一个socket连接到127.0.0.1:8081，并发送内容
    conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    conn.connect(("127.0.0.1", 8088))
    for i in range(1, 20000000):
    #等待服务端返回数据，并输出
        conn.send("hi,I'm NO."+ str(i))
        rev = conn.recv(1024)
        #print ('get server msg:' + str(rev))

threads = []
times = 20000
#并发
for i in range(0,times):
    t = threading.Thread(target=connToServer())
    threads.append(t)
for i in range(0,times):
    threads[i].start()
for i in range(0,times):
    threads[i].join()


